home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
FROMUTS
/
UNIXLIB37B
/
src
/
c
/
memchr
< prev
next >
Wrap
Text File
|
1990-09-27
|
797b
|
42 lines
#ifdef __STDC__
static char sccs_id[] = "@(#) memchr.c 1.0 "__DATE__" HJR";
#else
static char sccs_id[] = "@(#) memchr.c 1.0 26/9/90 HJR";
#endif
/* memchr.c (c) Copyright 1990 H.Rogers */
#include <string.h>
#ifdef __STDC__
void *memchr(register const void *s,register int c,register size_t n)
#else
void *memchr(s,c,n)
register const void *s;
register int c;
register size_t n;
#endif
{
register unsigned char *_s = (unsigned char *)s;
while (n & 0x07)
{
n--;
if (*_s++ == c) { ret: return((void *)(--_s)); }
}
n >>= 3; while (n)
{
n--;
if (*_s++ == c) goto ret;
if (*_s++ == c) goto ret;
if (*_s++ == c) goto ret;
if (*_s++ == c) goto ret;
if (*_s++ == c) goto ret;
if (*_s++ == c) goto ret;
if (*_s++ == c) goto ret;
if (*_s++ == c) goto ret;
}
return(0);
}